/*
 * Copyright (c) 2015-2019 广东口袋零钱信息技术有限公司 All Rights Reserved.
 */

package com.hxh.unified.param.check.utils;


import com.hxh.unified.param.check.vo.ResultVo;

/**
 * @author huangxunhui
 * Date: Created in 18/8/20 上午11:05
 * Utils: Intellij Idea
 * Description: 返回数据工具类
 */
public class ResultVoUtil {

    /**
     * 成功
     */
    private static final String SUCCESS = "00";

    /**
     * 失败
     */
    private static final String FAILURE = "-1";

    /**
     * 私有化工具类 防止被实例化
     * j
     */
    private ResultVoUtil() {}

    /**
     * 成功
     * @return 返回空
     */
    public static ResultVo success() {
        return success(null);
    }

    /**
     * 成功
     * @param object 需要返回的数据
     * @return data
     */
    public static ResultVo success(Object object) {
        ResultVo result = new ResultVo();
        result.setCode(SUCCESS);
        result.setMessage("操作成功");
        result.setData(object);
        return result;
    }

    /**
     * 错误
     * @param code 状态码
     * @param msg 消息
     * @return ResultVo
     */
    public static ResultVo error(String code, String msg) {
        ResultVo result = new ResultVo();
        result.setCode(code);
        result.setMessage(msg);
        return result;
    }

    /**
     * 错误
     * @param msg 错误信息
     * @return ResultVo
     */
    public static ResultVo error(String msg) {
        return error(FAILURE, msg);
    }

}
